package com.zc.vertx.demo;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.Router;

/**
 * Created by CZC70 on 2017/6/1.
 */
public class Server {

    public static void main(String[] args){
        Vertx vertx = Vertx.vertx();
        HttpServer server = vertx.createHttpServer();

        Router router = Router.router(vertx);


        Route router1 = router.route("/some/path/").handler(routingContext -> {
            HttpServerResponse response = routingContext.response();
            response.setChunked(true);
            response.write("route1\n");
            routingContext.vertx().setTimer(5000, tid -> routingContext.next());
        });
        server.requestHandler(router::accept).listen(8080);
    }
}
